import { useEffect } from "./useEffect";

export interface UseIntervalOptions {
  immediate?: string;
}

export function useInterval(fn: () => void, interval: number, immediate?: boolean) {
  if (immediate) {
    fn();
  }

  useEffect(() => {
    const intervalId = setInterval(fn, interval);
    return () => {
      clearInterval(intervalId);
    };
  });
}
